<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML >
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title> </title>
     
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
	<script type="text/javascript">
	
	wx.config({
	    //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
	    
	    appId: '${appid}', // 必填，公众号的唯一标识 
	    timestamp: '${jsApi.timestamp}', // 必填，生成签名的时间戳
	    nonceStr: '${jsApi.noncestr}', // 必填，生成签名的随机串
	    signature: '${jsApi.sign}',// 必填，签名，见附录1 
	    jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
		//jsApiList:["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo", "onMenuShareQZone", "hideMenuItems", "showMenuItems", "hideAllNonBaseMenuItem", "showAllNonBaseMenuItem", "translateVoice", "startRecord", "stopRecord", "onVoiceRecordEnd", "playVoice", "onVoicePlayEnd", "pauseVoice", "stopVoice", "uploadVoice", "downloadVoice", "chooseImage", "previewImage", "uploadImage", "downloadImage", "getNetworkType", "openLocation", "getLocation", "hideOptionMenu", "showOptionMenu", "closeWindow", "scanQRCode", "chooseWXPay", "openProductSpecificView", "addCard", "chooseCard", "openCard"]
	});
	
	wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
	   /*  wx.updateAppMessageShareData({ 
	        title: ' ddd', // 分享标题
	        desc: ' daasdd ', // 分享描述
	        link: 'http://li.hk1.mofasuidao.cn/winImg/WeixinServlet', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
	        imgUrl: 'http://li.hk1.mofasuidao.cn/winImg/image/egg.jpg', // 分享图标
		}, function(res) { 
			//这里是回调函数 
			console.info("回调函数")
			console.info(res);
		});  */
		var r = Math.random();
		r = parseInt(r*100000);
	    wx.onMenuShareAppMessage({
	        title: ' ',
	        desc: ' ',
	        link: 'http://li.hk1.mofasuidao.cn/winImg/WeixinServlet?r='+r+'&from=singlemessage', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
	        imgUrl: 'http://li.hk1.mofasuidao.cn/winImg/image/egg.jpg', // 分享图标
	        trigger: function (res) {
	          // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
	          //alert('用户点击发送给朋友');
	        },
	        success: function (res) {
	          //alert('已分享');
	        },
	        cancel: function (res) {
	          //alert('已取消');
	        },
	        fail: function (res) {
	          //alert(JSON.stringify(res));
	        }
	      });
	      
	});
	
	/* wx.checkJsApi({
	    jsApiList: [
	        'getLocation',
	        'onMenuShareTimeline',
	        'onMenuShareAppMessage'
	    ],
	    success: function (res) {
	        alert(JSON.stringify(res));
	    }
	});  */
	</script>
  </head>
  
  <body>
    <img alt="" src="image/egg2.jpg" width="100%" height="100%"> 
  </body>
</html>
